import pinia from '@/store'
import useUserStore from '@/store/modules/user'

export const isHasButton = (app: any) => {
  //全局自定义指令：实现按钮权限
  app.directive('has', {
    //代表使用全局自定义指令的DOM或组件挂载完毕时执行一次
    mounted(el: any, binding: any) {
      let userStore = useUserStore(pinia)
      if (!userStore.buttons.includes(binding.value)) {
        el.parentNode.removeChild(el)
      }
    },
  })
}
